package ms.unicorn.dsl.runtime;

import java.util.Collection;

import ms.unicorn.dsl.unicornDSL.XExpression;
import ms.unicorn.dsl.unicornDSL.XFunctionDeclaration;


public interface ExecutionContext {
	ExecutionContext getParent();
	ExecutionContext getCallerContext();
	Object getThisObject();
	void setThisObject(Object value);
	
	VariableStorage allocateVariable(int type, boolean global, String qualifiedName, Object value);
	VariableStorage addVariable(String qualifiedName, VariableStorage variable);
	VariableStorage getVariable(String qualifiedName, boolean allowCreateNew, boolean recursive);
	<T> T getVariableValueWithDefault(String qualifiedName, T defaultValue);
	<T> T getVariableValue(String qualifiedName, Class<T> expected);
	
	XExpression getEvaluatingExpression();
	void setEvaluatingExpression(XExpression expression);

	ExecutionContext getRootContext();
	
	ExecutionContext createChildContext();
	ExecutionContext createCalleeContext();
	ExecutionContext createDependentContext();
	
	Collection<VariableStorage> getVariables(int varType);
	Collection<String> getVariableNames(int varType);
	
	XFunctionDeclaration getExecutingFunction();
	void setExecutingFunction(XFunctionDeclaration func);
	
	void clearVariables();
}
